class ApplicationController < ActionController::Base

  before_action :access_log

  private

  def access_log

    logger = Logger.new(STDOUT)
    logger.info "request.path -> #{request.path}"
    if user_signed_in?
      access_log_count = AccessLog.where("user_id = '#{current_user.id}' and created_at like '#{Time.now.strftime('%F')}%' and method = '#{request.method}' and fullpath = '#{request.path}' ").count
      if access_log_count == 0
        accessLog = AccessLog.new(:user_id => current_user.id, :method => request.method, :ip => request.ip, :fullpath => request.path)
        accessLog.save
      end
    end
  end
end
